<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * Ajax Update Node Title Action
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 03.06.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/

    /***
    * class ajaxUpdatePage
    ****
    * This class will update the title of the given page
    ****
    * @package ajax
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 03.06.2005
    * @copyright essentialmind.com 2005
    ***/
    class ajaxUpdatePage extends ajaxAction{

        public function process(){
            //set variables
            $title  = (string)trim($this->unescape($_REQUEST['value']));            
            $id     = (int)$_REQUEST['id'];
            $title  = htmlspecialchars($title);
            
            //echo $title;exit;
            
            //see if we can handle the request
            try{
                $myPageInsert = new pageInserter($this->db, $this->log);
                $myPageInsert->updatePage($id,$title);
				
                //log action
                $this->log->recordAction("Ajax: Updated name of page ($id) to \"$title\"");
            }catch(Exception $e){
                $this->log->recordError("Ajax: Could not set new title for page $id");
            }
            
            $this->smarty->assign('title',$title);
            $this->smarty->assign('id',$id);		
            $this->r->html = $this->smarty->preFetch('ajax'.DIRECTORY_SEPARATOR.'pageupdate.html');
        }
    }
?>